#include <stdlib.h>   
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <errno.h>

#include "script_parser.h"
#include "commands.h"
#include "ready_queue.h"

static void
read_mmap ( char *file_name, size_t mem_size )
{
    int fd;
    script_dict *script_map;
    fd = open( file_name, O_RDWR , 0666); //6:rw, 7:rwx

    if( fd < 0)
    {
        int myerr = errno;
        printf("ERROR: open failed (errno %d %s)\n", myerr, strerror(myerr));
    }

    script_map = (script_dict *)mmap( 0, mem_size, PROT_READ, MAP_SHARED, fd, 0);

    printf("%s",(script_map[0].script_elem));
    puts(script_map[0].script_val);
    printf("tsc : %d\n",script_map[0].tsc);
    printf("proir : %d\n",script_map[0].priority);
    printf("burst : %d\n", script_map[0].burst_time);

    close(fd);
}

int main(int argc, char *argv[])
{
    read_mmap ( argv[0] , sizeof(script_dict) );
    
    return 0;
}

